Thread:       HOW TO DO This
Message:      00003_0004
From:         merlyn@some.web.address.com
Text:

>>>>> "Thomas" == Thomas Sweden <Thomas.Sweden@hp.com> writes:

Thomas> Why do you need a perl script when a shell script (or batch 
script,
Thomas> depending on OS) would do the job just fine..

Thomas> #!/bin/sh
Thomas> cd FIRST ; ls * | while read FLNAME

Please don't do this.  You're saying:

1) shell, please expand *
2) ls, please list each of these 1000 files.  Oh, and if any are 
directories
   expand their contents for me
3) shell, please read a line that may have one name on it, or a hundred

You really just wanted:

for FLNAME in *

because that starts far fewer processes and is far more secure from
filenames that contain whitespace

Thomas> do
Thomas> 	/path/to/appl -$FLNAME
Thomas> done

Thomas> In perl you'd have to either mess with Globs or pipe all sorts 
of stuff,
Thomas> which, IMHO, is un-necessary.

Not really.  In Perl, this would be:

}

Or even shorter:

Don't be dissing Perl in my presence. :)

You could even do this from the command line:

perl -e 'system "/path/to/appl", "-$_" for @ARGV' *

-- 
Randal L. Schwartz
<merlyn@some.web.address.com> <URL:http://www.some.web.address.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl 
training!

_X_X_X_X_X_X_X_X_X_X_
_X_X_X_X_X_X_X_X_X_X_


Thread:       HOW TO DO This
Message:      00002_0005
From:         "fd809" <fd809@some.web.address.com>
Text:

I have folder called FIRST....
I have 1000 files inside that folder.....
I also have an application that runs on each of these files.......(I
mean the application is called say : appl...
the command is: appl -file1=20=20

i need to execute this command on each of these 1000 files.....
SO how do i write a perl script so that this command is automatically
executed for each of those 1000 files in this folder.

_X_X_X_X_X_X_X_X_X_X_
_X_X_X_X_X_X_X_X_X_X_


Thread:       HOW TO DO This
Message:      00002_0006
From:         Thomas Sweden <Thomas.Sweden@some.web.address.com>
Text:

Why do you need a perl script when a shell script (or batch script,
depending on OS) would do the job just fine..

#!/bin/sh
cd FIRST ; ls * | while read FLNAME
do
/path/to/appl -$FLNAME
done

In perl you'd have to either mess with Globs or pipe all sorts of stuff,
which, IMHO, is un-necessary.

_X_X_X_X_X_X_X_X_X_X_
_X_X_X_X_X_X_X_X_X_X_


Thread:       HOW TO DO This
Message:      00002_0008
From:         "Derwood Davis" <dustin@some.web.address.com>
Text:

Not too difficult to open the directory (opendir), read all the files into
an array (@array =3D readdir()) and loop through the array (foreach)...

_X_X_X_X_X_X_X_X_X_X_
_X_X_X_X_X_X_X_X_X_X_


